<?php
class LoginView {
	// Define and assign private variables
	private $inputName = "name";
	private $inputPassword = "password";
	private $loginButton = "login";
	private $logoutButton = "logout";
	private $checkboxRemember = "rememberMe";
	
	public function createLoginBox() {
		// Returns xhtml string (a loginbox)
		return "<div id='container'><form action='' method='get'>
					<fieldset>
						<label for='$this->inputName'>Namn:</label> <input type='text' id='$this->inputName' name='$this->inputName' /> <br /> 
						<label for='$this->inputPassword'>Lösenord:</label> <input type='password'  id='$this->inputPassword' name='$this->inputPassword' /> <br />
						<input type='submit' name='$this->loginButton' value='Logga in' /> <label for='$this->checkboxRemember'>Kom ihåg mig</label> <input type='checkbox' checked='checked' name='$this->checkboxRemember' id='$this->checkboxRemember'/>
					</fieldset>
					</form>
					<p class='notLoggedIn'>Inte inloggad</p>
					<p class='errorMessage'>Fel användarnamn eller lösenord</p>";
	}

	public function createLogoutBox() {
		return "<form action='' method='get'> 
				<input type='submit' name='$this->logoutButton' value='Logga ut' />
				</form>";
	}

	public function getUserName() {
		// Get and return name, if name has been input
		if(isset($_GET[$this->inputName]) == true) {
			return $_GET[$this->inputName];
		} else {
			return null;
		};
	}

	public function getPassword() {
		// Get and return password, if password has been input
		if(isset($_GET[$this->inputPassword]) == true) {
			return $_GET[$this->inputPassword];
		} else {
			return null;
		};
	}

	public function triedToLogin() {
		// Returns true if login button has been clicked, else returns false
		if(isset($_GET[$this->loginButton]) == true) {
			return true;
		}
		else {return false;}

	}
	public function triedToLogout(){
		// Returns true if logout button has been clicked, else returns false
		if(isset($_GET[$this->logoutButton]) == true) {
			return true;
		}
		else {return false;}
	}

}
?>